<?php
    include_once 'fun.php';
    include_once 'islogin.php';
    $_SESSION['isadmin']=isset($_SESSION['isadmin'])?$_SESSION['isadmin']:'';
  if ($_SESSION['isadmin']!=2&&$_SESSION['isadmin']!=-1) {
      header('Refresh:1;url=shop.php');
      die("请以柜台管理员身份登录");
  }
    $id=$_GET['id'];
    $con=connect();
    $sql="select productid from counter where counterid=$id";
    $res=query($sql,$con);
    $a=mysqli_fetch_row($res);
    $productid = $a[0];
    if(!$productid)
    {echo "<script>
			
        location.href='counter.php';
    </script>";
    exit;}
    $sql = "update counter set productid = null where counterid=$id";
    query($sql,$con);
    $sql = "update product set stocknum = stocknum+counternum where productid=$productid";
    query($sql,$con);
    $sql = "update product set counternum = 0 where productid=$productid";
    query($sql,$con);
    echo "<script>
			
			location.href='counter.php';
	</script>";
